package project.newCode.gui;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.EventQueue;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Set;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import project.newCode.testRenderer;
import project.newCode.lights.Light;
import project.newCode.scenegraph.Component;

import java.awt.GridLayout;

public class Lightpanel extends JFrame {

	private JPanel contentPane;


	/**
	 * Create the frame.
	 * @param strings 
	 */
	public Lightpanel(testRenderer t) {
		HashMap<String,Light> lights = t.getScene().getLightsHashMap();
		String[] strings = t.getScene().getLightNames();
		Set<String> names = lights.keySet();
		int N = names.size();
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(new GridLayout((int) Math.ceil(N/3), Math.min(N,3), 0, 0));
		for(String name: names){
			LightSubPanel j = new LightSubPanel(name,lights.get(name),t);
			j.validate();
			boolean present = false;
			for (int i=0; i<strings.length; i++) {
				if(name.equals(strings[i])) present = true;
			}
			if(!present) {
				j.disableAll();
			}
			contentPane.add(j);
		}
		contentPane.validate();
		pack();
	}
	

}
